﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace GoldenAgeHelper.globel
{
    public class Setting
    {
        private static Hashtable hash = new Hashtable();
        static Setting() { Init(); }
        public static void Add(string key, string value)
        {
            //hash.Add(key, value);
            hash[key] = value;
        }

        public static object Get(object key)
        {
            if (hash.Contains(key))
            {
                return hash[key];
            }
            return null;
        }

        public static string GetString(object key)
        {
            return Get(key).ToString();
        }

        public static int GetInt(object key)
        {
            int i = 0;
            int.TryParse(Get(key) + "", out i);
            return i;
        }

        public static bool GetBool(object key)
        {
            bool b;
            bool.TryParse(Get(key) + "", out b);
            return b;

        }

        public static void Set(object key, object value)
        {
            hash[key] = value;
        }

        public static void SetString(object key, string value)
        {
            Set(key, value);
        }

        public static void SetInt(object key, int value)
        {
            Set(key, value);
        }

        public static void AddInt(object key, int value)
        {
            Set(key, GetInt(key) + value);
        }

        public static void SetBool(object key, bool value)
        {
            Set(key, value);
        }

        public static bool ContainsValue(object value)
        {
            return hash.ContainsValue(value);
        }

        public static bool ContainsKey(object key)
        {
            return hash.ContainsKey(key);
        }

        public static void Init()
        {
            hash["addtime"] = 0;
        }
    }
}
